package com.chaokang.controller;

import com.chaokang.dao.entity.CommonUserEntity;
import com.chaokang.dao.entity.GroupEntity;
import com.chaokang.dao.entity.GroupMemberEntity;
import com.chaokang.service.GroupMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
public class GroupMemberController {
    @Autowired
    GroupMemberService groupMemberService;

    @PostMapping("/service/insertGroupMember")
    public HashMap<String,Integer> insertGroupMember(@RequestBody GroupMemberEntity groupMemberEntity){
        HashMap map = new HashMap();

        map.put("success",groupMemberService.insertGroupMember(groupMemberEntity));;
        return map;
    }
    @PostMapping("/service/getGroupByUserId")
    public List<GroupEntity> getGroupByUserId(@RequestBody GroupEntity groupEntity){
        return groupMemberService.getGroupByUserId(groupEntity);
    }
    @PostMapping("/service/getGroupMemberByGroupId")
    public List<CommonUserEntity> getGroupMemberByGroupId(@RequestBody GroupMemberEntity groupMemberEntity){
        return groupMemberService.getGroupMemberByGroupId(groupMemberEntity);
    }
    @PostMapping("/service/deleteGroupMember")
    public HashMap deleteGroupMember(@RequestBody GroupMemberEntity groupMemberEntity){
        HashMap<String,Object> map = new HashMap();
        map.put("success",groupMemberService.deleteGroupMember(groupMemberEntity));
        return map;
    }
    @PostMapping("/service/addNewGroup")
    public HashMap addNewGroup(@RequestBody  GroupEntity groupEntity){
        HashMap<String,Object> map = new HashMap();
        map.put("success",groupMemberService.addGroup(groupEntity));
        return map;
    }
}
